package com.tomehay.termprojectmanage_server.controller;


import com.tomehay.termprojectmanage_server.enums.ResponseCode;
import com.tomehay.termprojectmanage_server.pojo.Model.Course;
import com.tomehay.termprojectmanage_server.pojo.VO.ResultVO;
import com.tomehay.termprojectmanage_server.service.CourseService;
import com.tomehay.termprojectmanage_server.utils.IDWorker;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author tomehay
 * @since 2023-06-20
 */
@RestController
@RequestMapping("/api/course")
public class CourseController {

    @Autowired
    CourseService courseService;

    @RequestMapping("/GetUnderGoCoursesByID")
    public ResultVO<List<Course>> GetUnderGoCoursesByID(int teacher_id){
        return courseService.GetUnderGoCoursesByID(teacher_id);
    }

    @RequestMapping("/GetUnderGoCoursesByStudentID")
    public ResultVO<List<Course>> GetUnderGoCoursesByStudentID(int id){
        return courseService.GetUnderGoCoursesByStudentID(id);
    }

    @RequestMapping("/GetEndedCoursesByStudentID")
    public ResultVO<List<Course>> GetEndedCoursesByStudentID(int id){
        return courseService.GetEndedCoursesByStudentID(id);
    }

    @RequestMapping("/GetEndedCoursesByID")
    public ResultVO<List<Course>> GetEndedCoursesByID(int teacher_id){
        return courseService.GetEndedCoursesByID(teacher_id);
    }

    @RequestMapping("/GetOneCoursesByID")
    public ResultVO<Course> GetOneCoursesByID(int id){
        return courseService.GetOneCoursesByID(id);
    }

    @PostMapping("/CreateCourse")
    public ResultVO<Void> CreateCourse(@RequestBody Course course){
        System.out.println(course);
        return courseService.CreateCourse(course);
    }

    @DeleteMapping("/DeleteCourse")
    public ResultVO<Void> DeleteCourse(int course_id){
        return courseService.DeleteCourse(course_id);
    }

    @GetMapping("/EndCourse")
    public ResultVO<Void> EndCourse(@RequestParam  int id){
        return courseService.EndCourse(id);
    }

    @GetMapping("/getAllCourse")
    public ResultVO<List<Course>> getAllCourse(@RequestParam("clazz_id") int id){
        return courseService.getAllCourse(id);
    }
}
